<template>
  <div class="confirm-dialog-overlay">
    <div class="confirm-dialog">
      <p>{{ message }}</p>
      <div class="confirm-dialog-actions">
        <button @click="$emit('cancel')">取消</button>
        <button @click="$emit('confirm')" class="confirm">确认</button>
      </div>
    </div>
  </div>
</template>

<script lang="ts" setup>
defineProps<{
  message: string;
}>();

defineEmits<{
  (e: 'confirm'): void;
  (e: 'cancel'): void;
}>();
</script>

<style scoped lang="less">
.confirm-dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.confirm-dialog {
  background-color: #fff;
  padding: 24px;
  border-radius: 8px;
  width: 90%;
  max-width: 400px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);

  p {
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 1.1em;
  }

  &-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;

    button {
      padding: 8px 16px;
      border: none;
      border-radius: 4px;
      cursor: pointer;
      font-size: 1em;

      &.confirm {
        background-color: #f44336;
        color: #fff;

        &:hover {
          background-color: #d32f2f;
        }
      }
    }
  }
}
</style>